package com.yuw.control.common;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet(name = "ServletAjaxDemo", value = "/ServletAjaxDemo")
public class ServletAjaxDemo extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 获取请求的参数
        String strId = request.getParameter("id");

        // 调用 model层进行业务逻辑处理
        // 使用response将ajax响应的内容以字节流的形式发回客户端
        PrintWriter printWriter = response.getWriter();
        // 写出数据流
        printWriter.write("ok");
        // 清空数据流
        printWriter.flush();
    }

}
